package com.ruoyi.function.constant;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;

import static javax.swing.UIManager.put;

public class ServiceTypeMapping {
    // 服务类型映射表（ID为key，中文名为value）
    private static final Map<Integer, String> SERVICE_MAP = new HashMap<Integer, String>() {{
        put(2, "保养");
        put(3, "贴膜");
        put(4, "凹痕修复");
        put(5, "粗洗");
        put(6, "精洗");
        put(7, "小件安装");
        put(8, "故障排查");
        put(9, "补胎");
        put(10, "换胎");
        put(13, "失火搭电");
        put(14, "拖车救援");
        put(15, "事故处理");
        put(16, "检修");
    }};


    /**
     * 将服务ID字符串转换为中文名称
     * @param idsStr 如 "2,3,4,5,6,7"
     * @return 中文名称，如 "保养,贴膜,凹痕修复,粗洗,精洗,小件安装"
     */
    public static String convertServiceIdsToChinese(String idsStr) {
        return Arrays.stream(idsStr.split(","))
                .map(String::trim)
                .filter(s -> !s.isEmpty())
                .map(idStr -> {
                    try {
                        int id = Integer.parseInt(idStr); // 转换确保ID为数字
                        return SERVICE_MAP.getOrDefault(id, "");
                    } catch (NumberFormatException e) {
                        return "";
                    }
                })
                .filter(name -> !name.isEmpty())
                .collect(Collectors.joining(","));
    }
}
